import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface registerGroupState {
    registerGroupData: any,
    activityTypeObj: any,
    registerStatus: string
}

const initialState: registerGroupState = {
    registerGroupData: {
        tags: [],
        imgUrls: [],
    },
    activityTypeObj: {},
    registerStatus: "create"
};

const registerGroupSlice = createSlice({
    name: 'registerGroup',
    initialState,
    reducers: {
        setRegisterGroupData(state, action) {
            state.registerGroupData = { ...state.registerGroupData, ...action.payload };
        },
        setActivityTypeObj(state, action) {
            state.activityTypeObj = action.payload.activityTypeObj;
        },
        setRegisterStatus(state, action) {
            state.registerStatus = action.payload.registerStatus;
        },
        initRegisterGroupData(state, action) {
            state.registerGroupData = {
                tags: [],
                imgUrls: [],
            };
        },
    },
});

export const { setRegisterGroupData, setActivityTypeObj, initRegisterGroupData, setRegisterStatus } = registerGroupSlice.actions;
export default registerGroupSlice.reducer;
